package com.yupi.springbootinit.manager;

import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.yucongming.dev.client.YuCongMingClient;
import com.yupi.yucongming.dev.common.BaseResponse;
import com.yupi.yucongming.dev.model.DevChatRequest;
import com.yupi.yucongming.dev.model.DevChatResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: wenjupeng
 * @Date: 2025/02/12/15:18
 * @Description:
 * @Param:
 * @return:
 */
@Service
public class AiManager {
    @Resource
    private YuCongMingClient yuCongMingClient;
    
    /**
     * AI对话
     * @param message
     * @return
     */
    public String doChat(long modelId,String message){
        DevChatRequest devChatRequest = new DevChatRequest();
        //devChatRequest.setModelId(1651468516836098050L);
        //devChatRequest.setModelId(1659171950288818178L);
        devChatRequest.setModelId(modelId);
        //System.out.println(modelId);
        devChatRequest.setMessage(message);

        // 获取响应
        BaseResponse<DevChatResponse> response = yuCongMingClient.doChat(devChatRequest);
       // System.out.println(response.getData());
        if(response == null){
            throw new BusinessException(ErrorCode.SYSTEM_ERROR,"AI 响应错误");
        }
        return response.getData().getContent();
    }
}
